package net.digitalartwork.ui{
	//import flash.filters.DropShadowFilter;
	//import fl.transitions.*;
	//import fl.transitions.easing.*;
	import flash.display.Stage;
	import flash.display.MovieClip;
	import flash.events.*;
	import flash.display.*;
	import flash.text.*;
	import net.digitalartwork.text.*;
	import gs.TweenFilterLite;
	import gs.easing.*;
	
	import net.digitalartwork.ui.ImageMaker;

	

	public class TooltipThumbnail extends Sprite{
		var toolText:TextMaker = new TextMaker;
		var theTip:Sprite = new Sprite();
		var bg:Sprite;
		var currentText:String;
		var heldVar:String;
		var ti:ImageMaker;
		
		public function TooltipThumbnail(hex:Number,hex2:Number) {
			bg = new Sprite();
			theTip.name = "tooltip";
			addChild(theTip);

			//var toolText:TextMaker = new TextMaker;
			25
			16
			var w:Number = 29;
			var h:Number = 20;
			bg.name = "background";
			theTip.addChildAt(bg, 0);

			bg.graphics.beginFill(0xFFFFFF);
			bg.graphics.lineStyle(1, 0x000000, w);
			bg.graphics.moveTo(0, 0);
			bg.graphics.lineTo(w+15, 0);
			bg.graphics.lineTo(w+15, h+10);
			bg.graphics.lineTo(20, h+10);
			bg.graphics.lineTo(15, h+20);
			bg.graphics.lineTo(10, h+10);
			bg.graphics.lineTo(0, h+10);
			bg.graphics.lineTo(0, 0);
			bg.graphics.endFill();
			theTip.visible = false;
		}

		public function showTip(theImage:String):void {
			//delete bg;
			var w:Number = 34;
			var h:Number = 24;
			
			addChild(theTip);
			theTip.removeChild(bg);
			
			//bg = null;
			bg = new Sprite();
			theTip.addChildAt(bg, 0);
			bg.name = "background";
			
			theTip.addChildAt(bg, 0);
			
			ti = new ImageMaker(theImage, 30, 20);
			theTip.addChild(ti);
			TweenFilterLite.to(ti, .2, {colorMatrixFilter:{amount:1, saturation:0}, alpha:.5});
			
			bg.graphics.clear();
			bg.graphics.beginFill(0xFFFFFF);
			bg.graphics.lineStyle(1, 0x000000, w);
			bg.graphics.moveTo(0, 0);
			bg.graphics.lineTo(w, 0);
			bg.graphics.lineTo(w, h);
			bg.graphics.lineTo((w/2)+5, h);
			bg.graphics.lineTo((w/2), h+10);
			bg.graphics.lineTo((w/2)-5, h);
			bg.graphics.lineTo(0, h);
			bg.graphics.lineTo(0, 0);
			bg.graphics.endFill();
			
			bg.x = -10;
			bg.y = 0 - bg.height;
			ti.x = bg.x+2;
			ti.y = bg.y+2;
			//theTip.x = 200;
			//theTip.y = 200;
			
			
			theTip.visible = true;
			theTip.alpha = 0;
			theTip.scaleX = 0;
			theTip.scaleY = 0;
			TweenFilterLite.to(theTip, .5, {scaleX:1, scaleY:1, alpha:1, ease:Back.easeOut, dropShadowFilter:{color:0x000000, alpha:.75, blurX:5, blurY:5, angle:45, distance:3}});
			
		}
		public function highlightTip(theColor:Number, theTextColor:Number, theScale:Number, activeSat:Boolean):void {
			TweenFilterLite.to(bg, .5, {colorMatrixFilter:{colorize:theColor, amount:1}});
			TweenFilterLite.to(theTip, .5, {scaleX:theScale, scaleY:theScale, alpha:1, ease:Back.easeOut});
			if (activeSat) {
				TweenFilterLite.to(ti, .2, {colorMatrixFilter:{amount:1, saturation:1}, alpha:1});
			} else {
				TweenFilterLite.to(ti, .2, {colorMatrixFilter:{amount:1, saturation:0}, alpha:.5});
			}
			
			//TweenFilterLite.to(toolText, .5, {colorMatrixFilter:{colorize:theTextColor, amount:1}});
		}
		public function changeTip(theText:String):void {
			//delete bg;
			addChild(theTip);
			theTip.removeChild(bg);
			toolText.text = theText;
			//bg = null;
			bg = new Sprite();
			theTip.addChildAt(bg, 0);
			bg.name = "background";
			
			theTip.addChildAt(bg, 0);
			
			bg.graphics.beginFill(0xFFFFFF);
			bg.graphics.lineStyle(1, 0x000000, toolText.textWidth);
			bg.graphics.moveTo(0, 0);
			bg.graphics.lineTo(toolText.textWidth+15, 0);
			bg.graphics.lineTo(toolText.textWidth+15, toolText.textHeight+10);
			bg.graphics.lineTo(20, toolText.textHeight+10);
			bg.graphics.lineTo(15, toolText.textHeight+20);
			bg.graphics.lineTo(10, toolText.textHeight+10);
			bg.graphics.lineTo(0, toolText.textHeight+10);
			bg.graphics.lineTo(0, 0);
			bg.graphics.endFill();
			
			bg.x = -10;
			bg.y = 0 - bg.height;
			toolText.x = bg.x+5;
			toolText.y = bg.y+2;
			//theTip.x = 200;
			//theTip.y = 200;
			
			
			theTip.visible = true;

			//TweenFilterLite.to(theTip, .5, {scaleX:1, scaleY:1, alpha:1, ease:Back.easeOut, dropShadowFilter:{color:0x000000, alpha:.75, blurX:5, blurY:5, angle:45, distance:3}});
			
		}
		public function holdVar(theVarValue:String):void {
			heldVar = theVarValue;
		}
		public function getVar():String {
			return heldVar;
			//return "dude"
		}
		public function removeTip():void {
			removeChild(theTip);
		}
		public function getText():String {
			return this.currentText;
			//return "dude"
		}
		
	}
}




